﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/Site1.Master" AutoEventWireup="true" CodeBehind="Calendar.aspx.cs" Inherits="ES_Project.Pages.WebForm447" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  
  <link type="text/css" href="js/js/css/ui-lightness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />	
<link type="text/css" href="js/js/css/jquery.timeentry.css" rel="stylesheet" />
  <script type="text/javascript" src="js/js/jquery-1.4.4.min.js"></script>
  <script type="text/javascript" src="js/js/jquery-ui-1.8.10.offset.datepicker.min.js"></script>
  <script type="text/javascript" src="js/js/jquery.datepick-th.js"></script>
  <script type="text/javascript" src="js/js/jquery-ui-timepicker-addon.js"></script>
  <script type="text/javascript" src="js/js/jquery.timeentry.js"></script>
  <script type="text/javascript" src="js/js/jquery.timeentry.min.js"></script>
  <script type="text/javascript" src="js/js/jquery.timeentry.pack.js"></script>
<style type="text/css">

/* Overide css code กำหนดความกว้างของปฏิทินและอื่นๆ */ 
.ui-datepicker{

	width:170px;

	font-family:tahoma;

	font-size:11px;

	text-align:center;

}
/* css for timepicker */
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
</style>
    <style type="text/css">
        table{font-size:small;
margin-top: 0px;
    color: #000000;
}
TABLE {
	MARGIN-BOTTOM: 0px
}
        .style4
        {
            width: 1167px;
        }
    .DNNAlignright {
	TEXT-ALIGN: right
}
select,input,button,textarea,button{font:99% arial,helvetica,clean,sans-serif;}
INPUT {
	FONT: 700 small normal normal arial, helvetica, clean, sans-serif; COLOR: #057cc4; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px;
    text-align: left;
}
SELECT {
	FONT: 700 small normal normal arial, helvetica, clean, sans-serif; COLOR: #057cc4; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px
}
TEXTAREA {
	FONT: 700 small normal normal arial, helvetica, clean, sans-serif; COLOR: #057cc4; MARGIN-LEFT: 0px; MARGIN-RIGHT: 0px
}
TH {
	FONT-FAMILY: Tahoma, Arial, Helvetica; COLOR: #003366; FONT-SIZE: 12px; VERTICAL-ALIGN: baseline; FONT-WEIGHT: bold
}
        .style19
        {
            width: 47px;
        }
        .style20
        {
            width: 1167px;
            font-size: small;
        }
        .style35
        {
            height: 31px;
            width: 82px;
        }
        .style36
        {
            width: 1167px;
            height: 31px;
            font-size: 10pt;
        }
        .style37
        {
            width: 47px;
            height: 31px;
        }
        .style54
        {
            width: 82px;
        }
        .style55
        {
            width: 152px;
            text-align: right;
        }
        .style56
        {
            width: 175px;
        }
        .style57
        {
            width: 124px;
        }
        </style>
    <p>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
       </p>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate> 
            <table cellpadding="0" cellspacing="0" class="style2">
                <tr>
                    <td class="style35">
                        </td>
                    <td class="style36">
                        <strong>บันทึกปฏิทิน</strong></td>
                    <td class="style37">
                        </td>
                </tr>
                <tr>
                    <td class="style54">
                        &nbsp;</td>
                    <td class="style4">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style54">
                        &nbsp;</td>
                    <td class="style4">
                        <table style="width:100%;">
                            <tr>
                                <td>
                                    &nbsp;<asp:Calendar ID="Calendar1" runat="server" BackColor="#FFFFCC"  OnSelectionChanged="calendar_SelectionChanged"
                                        BorderColor="#FFCC66" BorderWidth="1px" DayNameFormat="Full" OnDayRender="Calendar1_DayRender"
                                        Font-Names="Verdana" Font-Size="8pt" ForeColor="#663399" Height="225px" 
                                        ShowGridLines="True" Width="1008px">
                                        <DayHeaderStyle BackColor="#FFCC66" Font-Bold="True" Height="1px" />
                                        <NextPrevStyle Font-Size="9pt" ForeColor="#FFFFCC" />
                                        <OtherMonthDayStyle ForeColor="#CC9966" />
                                        <SelectedDayStyle BackColor="#CCCCFF" Font-Bold="True" />
                                        <SelectorStyle BackColor="#FFCC66" />
                                        <TitleStyle BackColor="#990000" Font-Bold="True" Font-Size="9pt" 
                                            ForeColor="#FFFFCC" />
                                        <SelectedDayStyle BackColor="#FFCC66" ForeColor="White" />
                                    </asp:Calendar>
                                    
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style54">
                        &nbsp;</td>
                    <td class="style20">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style54">
                        &nbsp;</td>
                    <td class="style4">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style54">
                        &nbsp;</td>
                    <td class="style4">
                        <table style="width:100%;">
                            <tr>
                                <td class="style55">
                                    <strong>วันที่ :</strong></td>
                                <td class="style56">
                                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                </td>
                                <td class="style57" style="text-align: right">
                                    <strong>วัน :</strong></td>
                                <td>
                                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style55">
                                    &nbsp;</td>
                                <td class="style56">
                                    &nbsp;</td>
                                <td class="style57">
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                            <tr>
                                <td class="style55">
                                    <strong>หยุดเนื่องในวัน :</strong></td>
                                <td class="style56">
                                    <textarea ID="TextArea1" runat="server" cols="20" name="S1" rows="2"></textarea></td>
                                <td class="style57">
                                    &nbsp;</td>
                                <td>
                                    <asp:Button ID="CMD_INSERT" runat="server" OnClick="CMD_INSERT_Click" 
                            OnClientClick="return validate()" Text="  บันทึก  " Width="60px" />
                            <asp:Button ID="CMD_EDIT" runat="server" OnClick="CMD_INSERT_Click" 
                            Text="แก้ไข" />
                            <%--<asp:Button ID="CMD_CLEAR" runat="server" OnClick="CMD_CLEAR_Click" 
                             Text="  เคลียร์  " Width="60px" />--%>
                                </td>
                                <td>
                                    &nbsp;</td>
                                <td>
                                    &nbsp;</td>
                            </tr>
                        </table>
                    </td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style54">
                        &nbsp;</td>
                    <td class="style4">
                        <%--<asp:Button ID="CMD_INSERT" runat="server" OnClick="CMD_INSERT_Click" 
                            OnClientClick="return validate()" Text="  บันทึก  " Width="60px" />
                        <asp:Button ID="CMD_EDIT" runat="server" OnClick="CMD_INSERT_Click" 
                            Text="แก้ไข" />
                        <asp:Button ID="CMD_CLEAR" runat="server" OnClick="CMD_CLEAR_Click" 
                            OnClientClick="ClearDropDown()" Text="  เคลียร์  " Width="60px" />--%>
                    </td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style54">
                        &nbsp;</td>
                    <td class="style4">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
                <tr>
                    <td class="style54">
                        &nbsp;</td>
                    <td class="style4">
                        &nbsp;</td>
                    <td class="style19">
                        &nbsp;</td>
                </tr>
            </table>
      </ContentTemplate>
    </asp:UpdatePanel>
     <br />
    <script type="text/javascript">

        $(Sys.Application.add_load(function () {

            // alert();
            $("#ContentPlaceHolder1_empCode").focusout(function () {
                //  alert("fdfdf");
                document.getElementById('ContentPlaceHolder1_CMD_EmpCode').click();
            })
            $('#ContentPlaceHolder1_empClsStart').timepicker({});

            $("#ContentPlaceHolder1_clsRegCode").focusout(function () {
                //  alert("fdfdf");
                document.getElementById('ContentPlaceHolder1_CMD_CourseCode').click();
            })

        }));
    </script>
    <script type ="text/javascript">
        function gotoButton(e) {
            var keyPressed;
            if (window.event) {
                keyPressed = window.event.keyCode; // IE
                if (keyPressed == 13) {


                    //  document.getElementById("CMD_AgentCode").focus();
                    document.getElementById('ContentPlaceHolder1_CMD_EmpCode').click();
                }

            } else {
                keyPressed = e.which; // Firefox
                if (keyPressed == 13) {
                    document.getElementById('ContentPlaceHolder1_CMD_EmpCode').click();
                    //document.getElementById("CMD_AgentCode").focus();
                }

            }
        }

        function chButton() {

            if (document.getElementById("ContentPlaceHolder1_empCode").value == "") {
                alert("กรุณาระบุรหัสครูเพื่อค้นหาครูผู้สอน");
                //document.getElementById("AgentCode").focus();
                return (false);
            }
            if (document.getElementById("ContentPlaceHolder1_empCode").value.length != 2) {
                //alert("กรุณาระบุรหัสตัวแทนให้ครบ 6 หลัก");
                document.getElementById("ContentPlaceHolder1_empId").focus();
                return (false);
            }



            return true;

        } function gotoButton2(e) {
            var keyPressed;
            if (window.event) {
                keyPressed = window.event.keyCode; // IE
                if (keyPressed == 13) {


                    //  document.getElementById("CMD_AgentCode").focus();
                    document.getElementById('ContentPlaceHolder1_CMD_CourseCode').click();
                }

            } else {
                keyPressed = e.which; // Firefox
                if (keyPressed == 13) {
                    document.getElementById('ContentPlaceHolder1_CMD_CourseCode').click();
                    //document.getElementById("CMD_AgentCode").focus();
                }

            }
        }

        function chButton2() {

            if (document.getElementById("ContentPlaceHolder1_clsRegCode").value == "") {
                alert("กรุณาระบุรหัสครูเพื่อค้นหาครูผู้สอน");
                //document.getElementById("AgentCode").focus();
                return (false);
            }
            if (document.getElementById("ContentPlaceHolder1_clsRegCode").value.length != 2) {
                //alert("กรุณาระบุรหัสตัวแทนให้ครบ 6 หลัก");
                document.getElementById("ContentPlaceHolder1_clsRegId").focus();
                return (false);
            }



            return true;

        }

        function fromTime(time) { var x; return (x = String(time).match(/(\d+):(\d+)/)) ? (Number(x[1]) * 60) + Number(x[2]) : 0; }
        function toTime(seconds) { var x = Math.abs(seconds) % 60, y = (Math.abs(seconds) - x) / 60; return (seconds < 0 ? '-' : '') + (y < 10 ? '0' : '') + y + ':' + (x < 10 ? '0' : '') + x; }

        function calculateHour() {
            var a = document.getElementById("ContentPlaceHolder1_empClsStart").value;
            var b = document.getElementById("ContentPlaceHolder1_empClsEnd").value;
            var courseTime = document.getElementById("ContentPlaceHolder1_clsCourseTime").value;
            //alert(document.getElementById("ContentPlaceHolder1_clsCourseTime").value);
//            var c, d, e, f ;
//            var g = a.substring(0, 1);
//            var i = a.substring(3, 4);
//            var h = b.substring(0, 1);
//            var j = b.substring(3, 4);

            var z = toTime(fromTime(b) - fromTime(a));
            var y = z.replace(":", ".");
            document.getElementById("ContentPlaceHolder1_empClsHours").value = y;
            //var timeCal = z;
            //c = z.substring(0, 2);
            //d = z.substring(3, 5);
            //var timeCal = c + '.' + d;
            var timeCal = toTime(fromTime(z) * parseInt(courseTime));
            timeCal = timeCal.replace(":", ".");
            //alert(timeCal);
            //alert(timeCal);

                            //alert(courseTime);
                            //alert(timeCal);
            //var totalCal = eval(parseFloat(courseTime) * parseFloat(timeCal));
                            //document.getElementById("ContentPlaceHolder1_empClsTotalHours").value = Math.round(totalCal);
            document.getElementById("ContentPlaceHolder1_empClsTotalHours").value = timeCal;





            //document.getElementById("ContentPlaceHolder1_empClsTotalHours").value = z;
            //alert(z);
          // check ชั่วโมง ว่า string ตัวแรกเป็น 0 ไหม ถ้าเป็นเป็น ให้ตัดเฉพาะตัวสุดท้าย  
//            if (g == 0) {
//                 c = a.substring(1, 2);
//                 d = a.substring(3, 5);  
//            } else {
//                 c = a.substring(0, 2);
//                 d = a.substring(3, 5);
//            }

          // check นาที ว่า string ตัวแรกเป็น 0 ไหม ถ้าเป็นเป็น ให้ตัดเฉพาะตัวสุดท้าย
//             if (i == 0) {
//                 //c = a.substring(1, 2);
//                 d = a.substring(4, 5);
//             } else {
//                 //c = a.substring(0, 2);
//                 d = a.substring(3, 5);
//             }

          // check ชั่วโมง ว่า string ตัวแรกเป็น 0 ไหม ถ้าเป็นเป็น ให้ตัดเฉพาะตัวสุดท้าย 
//             if (h == 0) {
//                 e = b.substring(1, 2);
//                 f = b.substring(3, 5);
//             } else {
//                 e = b.substring(0, 2);
//                 f = b.substring(3, 5);
//             }

          // check นาที ว่า string ตัวแรกเป็น 0 ไหม ถ้าเป็นเป็น ให้ตัดเฉพาะตัวสุดท้าย
//             if (i == 0) {
//                 //c = a.substring(1, 2);
//                 f = b.substring(4, 5);
//             } else {
//                 //c = a.substring(0, 2);
//                 f = b.substring(3, 5);
//             }

             

//            var front = eval(parseInt(e) - parseInt(c));
//            var back = eval(parseInt(f) - parseInt(d));
//            if (isNaN(front) || isNaN(back)) {
//                document.getElementById("ContentPlaceHolder1_empClsHours").value = '0.0';
//            }
//            else if (front < 0 || back < 0) {

//                document.getElementById("ContentPlaceHolder1_empClsHours").value = '0.0';
//                var zero = '0.0';
//            } else {
//                //document.getElementById("ContentPlaceHolder1_empClsHours").value = front + '.' + back;
//                //var timeCal = front + '.' + back;
//                document.getElementById("ContentPlaceHolder1_empClsHours").value = z;
//                var timeCal = z;
//               

//                //alert(courseTime);
//                //alert(timeCal);
//                var totalCal = eval(parseFloat(courseTime) * parseFloat(timeCal));
//                //document.getElementById("ContentPlaceHolder1_empClsTotalHours").value = Math.round(totalCal);
//                document.getElementById("ContentPlaceHolder1_empClsTotalHours").value = totalCal;
//            }

            //alert(a.substring(0, 2));
            //alert(a.substring(3, 5));

        }
        function ClearDropDown() {
            //alert();
            document.getElementById("ContentPlaceHolder1_myDDL1").value = "";
        }

        function validate() {
            // alert(document.getElementById("ContentPlaceHolder1_empCode").value);
            if (document.getElementById("ContentPlaceHolder1_empCode").value == "") {
                alert('กรุณากรอกรหัสครู');
                return false;
            }
            if (document.getElementById("ContentPlaceHolder1_clsRegCode").value == "") {
                alert('กรุณากรอกรหัสวิชา');
                return false;
            }
            //            if (document.getElementById("ContentPlaceHolder1_empClsStart").value == "") {
            //                alert('กรุณากรอกเวลาเริ่มสอน');
            //                return false;
            //            }
            //            if (document.getElementById("ContentPlaceHolder1_empClsEnd").value == "") {
            //                alert('กรุณากรอกเวลาสิ้นสุด');
            //                return false;
            //            }


            return true;

        }

//        function calMoney() {
//            var pay = document.getElementById("ContentPlaceHolder1_empClsSal").value;
//            var radio = document.getElementById("ContentPlaceHolder1_radio").checked;
//            var radio1 = document.getElementsByTagName("ListItem").item;
//            alert(pay);
//            if (radio == true) {
//                alert(radio);
//            } else {
//            alert('dddd');
//            }
//            //alert(radio1);
//        
//        }
        
        
    </script> 
    <%--<script type="text/javascript">

        $(Sys.Application.add_load(function () {

            //alert();
            //$('#ContentPlaceHolder1_empClsStart').timepicker({});
            $('#ContentPlaceHolder1_empClsHours').timeEntry({ show24Hours: true });
        }));
                                    </script>--%>
</asp:Content>